home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 10 / AACD 10.iso / AACD / Games / MAME / src / vidhrdw / circus.c < prev    next >
C/C++ Source or Header  |  2000-05-13  |  9KB  |  385 lines

  1. /***************************************************************************
  2.  
  3.   vidhrdw.c
  4.  
  5.   Functions to emulate the video hardware of the machine.
  6.  
  7.   CHANGES:
  8.   MAB 05 MAR 99 - changed overlay support to use artwork functions
  9.  
  10. ***************************************************************************/
  11.  
  12. #include "driver.h"
  13. #include "vidhrdw/generic.h"
  14. #include "artwork.h"
  15.  
  16. static int clown_x=0,clown_y=0,clown_z=0;
  17.  
  18. /* The first entry defines the color with which the bitmap is filled initially */
  19. /* The array is terminated with an entry with negative coordinates. */
  20. /* At least two entries are needed. */
  21. static const struct artwork_element circus_ol[]={
  22.     {{  0, 255,  20,  35}, 0x20, 0x20, 0xff,   OVERLAY_DEFAULT_OPACITY},    /* blue */
  23.     {{  0, 255,  36,  47}, 0x20, 0xff, 0x20,   OVERLAY_DEFAULT_OPACITY},    /* green */
  24.     {{  0, 255,  48,  63}, 0xff, 0xff, 0x20,   OVERLAY_DEFAULT_OPACITY},    /* yellow */
  25.     {{ -1,  -1,  -1,  -1},    0,    0,    0,   0}
  26. };
  27.  
  28.  
  29. /***************************************************************************
  30. ***************************************************************************/
  31.  
  32. int circus_vh_start(void)
  33. {
  34.     int start_pen = 2;
  35.  
  36.     if (generic_vh_start()!=0)
  37.         return 1;
  38.  
  39.     overlay_create(circus_ol, start_pen, Machine->drv->total_colors-start_pen);
  40.  
  41.     return 0;
  42. }
  43.  
  44. /***************************************************************************
  45. ***************************************************************************/
  46.  
  47. WRITE_HANDLER( circus_clown_x_w )
  48. {
  49.     clown_x = 240-data;
  50. }
  51.  
  52. WRITE_HANDLER( circus_clown_y_w )
  53. {
  54.     clown_y = 240-data;
  55. }
  56.  
  57. /* This register controls the clown image currently displayed */
  58. /* and also is used to enable the amplifier and trigger the   */
  59. /* discrete circuitry that produces sound effects and music   */
  60.  
  61. WRITE_HANDLER( circus_clown_z_w )
  62. {
  63.     clown_z = (data & 0x0f);
  64.  
  65.     /* Bits 4-6 enable/disable trigger different events */
  66.     /* descriptions are based on Circus schematics      */
  67.  
  68.     switch ((data & 0x70) >> 4)
  69.     {
  70.         case 0 : /* All Off */
  71.             DAC_data_w (0,0);
  72.             break;
  73.  
  74.         case 1 : /* Music */
  75.             DAC_data_w (0,0x7f);
  76.             break;
  77.  
  78.         case 2 : /* Pop */
  79.             break;
  80.  
  81.         case 3 : /* Normal Video */
  82.             break;
  83.  
  84.         case 4 : /* Miss */
  85.             break;
  86.  
  87.         case 5 : /* Invert Video */
  88.             break;
  89.  
  90.         case 6 : /* Bounce */
  91.             break;
  92.  
  93.         case 7 : /* Don't Know */
  94.             break;
  95.     };
  96.  
  97.     /* Bit 7 enables amplifier (1 = on) */
  98.  
  99. //    logerror("clown Z = %02x\n",data);
  100. }
  101.  
  102. static void draw_line(struct osd_bitmap *bitmap, int x1, int y1, int x2, int y2, int dotted)
  103. {
  104.     /* Draws horizontal and Vertical lines only! */
  105.     int col = Machine->pens[1];
  106.  
  107.     int count, skip;
  108.  
  109.     /* Draw the Line */
  110.  
  111.     if (dotted > 0)
  112.         skip = 2;
  113.     else
  114.         skip = 1;
  115.  
  116.     if (x1 == x2)
  117.     {
  118.         for (count = y2; count >= y1; count -= skip)
  119.         {
  120.             plot_pixel(bitmap, x1, count, col);
  121.         }
  122.     }
  123.     else
  124.     {
  125.         for (count = x2; count >= x1; count -= skip)
  126.         {
  127.             plot_pixel(bitmap, count, y1, col);
  128.         }
  129.     }
  130. }
  131.  
  132. static void draw_robot_box (struct osd_bitmap *bitmap, int x, int y)
  133. {
  134.     /* Box */
  135.  
  136.     int ex = x + 24;
  137.     int ey = y + 26;
  138.  
  139.     draw_line(bitmap,x,y,ex,y,0);        /* Top */
  140.     draw_line(bitmap,x,ey,ex,ey,0);        /* Bottom */
  141.     draw_line(bitmap,x,y,x,ey,0);        /* Left */
  142.     draw_line(bitmap,ex,y,ex,ey,0);        /* Right */
  143.  
  144.     /* Score Grid */
  145.  
  146.     ey = y + 10;
  147.     draw_line(bitmap,x+8,ey,ex,ey,0);    /* Horizontal Divide Line */
  148.     draw_line(bitmap,x+8,y,x+8,ey,0);
  149.     draw_line(bitmap,x+16,y,x+16,ey,0);
  150. }
  151.  
  152.  
  153. void circus_vh_screenrefresh(struct osd_bitmap *bitmap,int full_refresh)
  154. {
  155.     int offs;
  156.     int sx,sy;
  157.  
  158.     if (palette_recalc() || full_refresh)
  159.     {
  160.         memset(dirtybuffer,1,videoram_size);
  161.     }
  162.  
  163.     /* for every character in the Video RAM,        */
  164.     /* check if it has been modified since          */
  165.     /* last time and update it accordingly.         */
  166.  
  167.     for (offs = videoram_size - 1;offs >= 0;offs--)
  168.     {
  169.         if (dirtybuffer[offs])
  170.         {
  171.             dirtybuffer[offs] = 0;
  172.  
  173.             sy = offs / 32;
  174.             sx = offs % 32;
  175.  
  176.             drawgfx(bitmap,Machine->gfx[0],
  177.                     videoram[offs],
  178.                     0,
  179.                     0,0,
  180.                     8*sx,8*sy,
  181.                     &Machine->drv->visible_area,TRANSPARENCY_NONE,0);
  182.         }
  183.     }
  184.  
  185.     /* The sync generator hardware is used to   */
  186.     /* draw the border and diving boards        */
  187.  
  188.     draw_line (bitmap,0,18,255,18,0);
  189.     draw_line (bitmap,0,249,255,249,1);
  190.     draw_line (bitmap,0,18,0,248,0);
  191.     draw_line (bitmap,247,18,247,248,0);
  192.  
  193.     draw_line (bitmap,0,137,17,137,0);
  194.     draw_line (bitmap,231,137,248,137,0);
  195.     draw_line (bitmap,0,193,17,193,0);
  196.     draw_line (bitmap,231,193,248,193,0);
  197.  
  198.     drawgfx(bitmap,Machine->gfx[1],
  199.             clown_z,
  200.             0,
  201.             0,0,
  202.             clown_y,clown_x,
  203.             &Machine->drv->visible_area,TRANSPARENCY_PEN,0);
  204.  
  205.     /* mark tiles underneath as dirty */
  206.     sx = clown_y >> 3;
  207.     sy = clown_x >> 3;
  208.  
  209.     {
  210.         int max_x = 2;
  211.         int max_y = 2;
  212.         int x2, y2;
  213.  
  214.         if (clown_y & 0x0f) max_x ++;
  215.         if (clown_x & 0x0f) max_y ++;
  216.  
  217.         for (y2 = sy; y2 < sy + max_y; y2 ++)
  218.         {
  219.             for (x2 = sx; x2 < sx + max_x; x2 ++)
  220.             {
  221.                 if ((x2 < 32) && (y2 < 32) && (x2 >= 0) && (y2 >= 0))
  222.                     dirtybuffer[x2 + 32*y2] = 1;
  223.             }
  224.         }
  225.     }
  226. }
  227.  
  228.  
  229. void robotbowl_vh_screenrefresh(struct osd_bitmap *bitmap,int full_refresh)
  230. {
  231.     int offs;
  232.     int sx,sy;
  233.  
  234.     if (full_refresh)
  235.     {
  236.         memset(dirtybuffer, 1, videoram_size);
  237.     }
  238.  
  239.     /* for every character in the Video RAM,  */
  240.     /* check if it has been modified since    */
  241.     /* last time and update it accordingly.   */
  242.  
  243.     for (offs = videoram_size - 1;offs >= 0;offs--)
  244.     {
  245.         if (dirtybuffer[offs])
  246.         {
  247.             dirtybuffer[offs] = 0;
  248.  
  249.             sx = offs % 32;
  250.             sy = offs / 32;
  251.  
  252.             drawgfx(bitmap,Machine->gfx[0],
  253.                     videoram[offs],
  254.                     0,
  255.                     0,0,
  256.                     8*sx,8*sy,
  257.                     &Machine->drv->visible_area,TRANSPARENCY_NONE,0);
  258.         }
  259.     }
  260.  
  261.     /* The sync generator hardware is used to   */
  262.     /* draw the bowling alley & scorecards      */
  263.  
  264.     /* Scoreboards */
  265.  
  266.     for(offs=15;offs<=63;offs+=24)
  267.     {
  268.         draw_robot_box(bitmap, offs, 31);
  269.         draw_robot_box(bitmap, offs, 63);
  270.         draw_robot_box(bitmap, offs, 95);
  271.  
  272.         draw_robot_box(bitmap, offs+152, 31);
  273.         draw_robot_box(bitmap, offs+152, 63);
  274.         draw_robot_box(bitmap, offs+152, 95);
  275.     }
  276.  
  277.     draw_robot_box(bitmap, 39, 127);                  /* 10th Frame */
  278.     draw_line(bitmap, 39,137,47,137,0);          /* Extra digit box */
  279.  
  280.     draw_robot_box(bitmap, 39+152, 127);
  281.     draw_line(bitmap, 39+152,137,47+152,137,0);
  282.  
  283.     /* Bowling Alley */
  284.  
  285.     draw_line(bitmap, 103,17,103,205,0);
  286.     draw_line(bitmap, 111,17,111,203,1);
  287.     draw_line(bitmap, 152,17,152,205,0);
  288.     draw_line(bitmap, 144,17,144,203,1);
  289.  
  290.     /* Draw the Ball */
  291.  
  292.     drawgfx(bitmap,Machine->gfx[1],
  293.             clown_z,
  294.             0,
  295.             0,0,
  296.             clown_y+8,clown_x+8, /* Y is horizontal position */
  297.             &Machine->drv->visible_area,TRANSPARENCY_PEN,0);
  298.  
  299.     /* mark tiles underneath as dirty */
  300.     sx = clown_y >> 3;
  301.     sy = clown_x >> 3;
  302.  
  303.     {
  304.         int max_x = 2;
  305.         int max_y = 2;
  306.         int x2, y2;
  307.  
  308.         if (clown_y & 0x0f) max_x ++;
  309.         if (clown_x & 0x0f) max_y ++;
  310.  
  311.         for (y2 = sy; y2 < sy + max_y; y2 ++)
  312.         {
  313.             for (x2 = sx; x2 < sx + max_x; x2 ++)
  314.             {
  315.                 if ((x2 < 32) && (y2 < 32) && (x2 >= 0) && (y2 >= 0))
  316.                     dirtybuffer[x2 + 32*y2] = 1;
  317.             }
  318.         }
  319.     }
  320.  
  321. }
  322.  
  323. void crash_vh_screenrefresh(struct osd_bitmap *bitmap,int full_refresh)
  324. {
  325.     int offs;
  326.     int sx,sy;
  327.  
  328.     if (full_refresh)
  329.     {
  330.         memset(dirtybuffer, 1, videoram_size);
  331.     }
  332.  
  333.     /* for every character in the Video RAM,    */
  334.     /* check if it has been modified since         */
  335.     /* last time and update it accordingly.     */
  336.  
  337.     for (offs = videoram_size - 1;offs >= 0;offs--)
  338.     {
  339.         if (dirtybuffer[offs])
  340.         {
  341.             dirtybuffer[offs] = 0;
  342.  
  343.             sx = offs % 32;
  344.             sy = offs / 32;
  345.  
  346.             drawgfx(bitmap,Machine->gfx[0],
  347.                     videoram[offs],
  348.                     0,
  349.                     0,0,
  350.                     8*sx,8*sy,
  351.                     &Machine->drv->visible_area,TRANSPARENCY_NONE,0);
  352.         }
  353.     }
  354.  
  355.     /* Draw the Car */
  356.     drawgfx(bitmap,Machine->gfx[1],
  357.             clown_z,
  358.             0,
  359.             0,0,
  360.             clown_y,clown_x, /* Y is horizontal position */
  361.             &Machine->drv->visible_area,TRANSPARENCY_PEN,0);
  362.  
  363.     /* mark tiles underneath as dirty */
  364.     sx = clown_y >> 3;
  365.     sy = clown_x >> 3;
  366.  
  367.     {
  368.         int max_x = 2;
  369.         int max_y = 2;
  370.         int x2, y2;
  371.  
  372.         if (clown_y & 0x0f) max_x ++;
  373.         if (clown_x & 0x0f) max_y ++;
  374.  
  375.         for (y2 = sy; y2 < sy + max_y; y2 ++)
  376.         {
  377.             for (x2 = sx; x2 < sx + max_x; x2 ++)
  378.             {
  379.                 if ((x2 < 32) && (y2 < 32) && (x2 >= 0) && (y2 >= 0))
  380.                     dirtybuffer[x2 + 32*y2] = 1;
  381.             }
  382.         }
  383.     }
  384. }
  385.